$(document).ready(function () {
  let width = $(window).width()
  let isMoble = width < 1200
  var swiper1 = new Swiper(".mySwiper", {
    slidesPerView: isMoble ? 1.6 : 3.6,
    centeredSlides: true,
    spaceBetween: 48,
    initialSlide: 3,
    centeredSlidesBounds: true,
    loop: true,
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".button-next",
      prevEl: ".button-prev",
    },
  });

  var swiper2 = new Swiper(".linkSwiper1", {
    observer: true,
    observeSlideChildren: true,
    observeParents: true,  //这三个可以去文档看下介绍，主要就是异步情况会重新加载swiper。
    loop: true, //开启环路
    speed: 1200, //每个轮播图过渡的时间
    slidesPerView: 'auto', //当前页面显示几个，这里是auto
    updateOnWindowResize: false,  //分辨率改变时，防止样式错乱加上！
    autoplay: {
      delay: 0,   //每循环一圈，间隔时间，无缝轮询，则为0
      stopOnLastSlide: false,
      disableOnInteraction: false,
    }
  });

  var swiper3 = new Swiper(".linkSwiper2", {
    observer: true,
    observeSlideChildren: true,
    observeParents: true,  //这三个可以去文档看下介绍，主要就是异步情况会重新加载swiper。
    loop: true, //开启环路
    speed: 1000, //每个轮播图过渡的时间
    slidesPerView: 'auto', //当前页面显示几个，这里是auto
    updateOnWindowResize: false,  //分辨率改变时，防止样式错乱加上！
    autoplay: {
      delay: 0,   //每循环一圈，间隔时间，无缝轮询，则为0
      stopOnLastSlide: false,
      disableOnInteraction: false,
    }
  });

  $(".model-box .tab-item").on("click", function (e) {
    if (!e.target || !e.target.dataset) return;
    let index = e.target.dataset.index;
    if (isNaN(Number(index)) || Number(index) < 0) return;
    $(this).removeClass("un-sign").siblings(".tab-item").addClass("un-sign");

    let parent = $(this).parent().parent();

    parent
      .children(".main-box")
      .eq(index)
      .removeClass("hidden-item")
      .siblings(".main-box")
      .addClass("hidden-item");

    parent
      .children(".button")
      .eq(index)
      .removeClass("hidden-item")
      .siblings(".button")
      .addClass("hidden-item");
  });

  $('#videoIframe').attr({ width: document.documentElement.scrollWidth * 0.8, height: document.documentElement.scrollWidth * 0.4 })
  // 视频展示
  $(document.body).on('click', '.videoWrap a', function (e) {
    e.preventDefault();
    var videoBox = dialog({
      title: 'Video',
      content: $('#videoBox')
    });
    $('#videoIframe').attr('src', $(e.target).is('a') ?  $(e.target).attr('media') : $(e.target).parents('a').attr('media'))
    setTimeout(function () {
      videoBox.showModal();
    }, 500)
  })

  // $(function () {
  //     $('.linkSwiper1 .swiper-wrapper').liMarquee();
  // });

  // $(function () {
  //     $('.linkSwiper2').liMarquee();
  // });
})